import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MainScreen extends JFrame
{
	private JTextField url;
	private JButton start;
	private JButton stop;
	private JButton resume;
	private JTextArea output;
	
	public MainScreen()
	{
		setup();
	}
	
	public String getStartingURL()
	{
		return url.getText();
	}
	
	public void addOutput(String toOutput)
	{
		output.setText(output.getText() + "\n" + toOutput);
	}
	
	private void setup()
	{
		setSize(500,500);
		setLocationRelativeTo(null);
		setTitle("XenoBot Controller");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		initButtons();
		
		JPanel mainPanel = new JPanel();
		mainPanel.setLayout(new GridLayout(3,1));
		
		JPanel urlPanel = new JPanel();
		urlPanel.add(new JLabel("Enter URL:"));
		url = new JTextField(20);
		urlPanel.add(url);
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new GridLayout(1,3));
		buttonPanel.add(start);
		buttonPanel.add(stop);
		buttonPanel.add(resume);
		
		JPanel outputPanel = new JPanel();
		output = new JTextArea();
		outputPanel.add(output);
		
		mainPanel.add(urlPanel);
		mainPanel.add(buttonPanel);
		mainPanel.add(output);
		
		add(mainPanel);
		
		setVisible(true);
	}
	
	private void initButtons()
	{
		start = new JButton("Start");
		start.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e)
			{
				output.setText(url.getText());
			}
		});
		
		stop = new JButton("Stop");
		resume = new JButton("Resume");
	}
}